﻿<!DOCTYPE html>

<html>

	<head>
		<meta charset="utf-8">
		<title>LMB-SVN - 用户管理</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<script src="${httpRootPath}/resources/layui/layui.js" charset="utf-8"></script>
		<script src="${httpRootPath}/resources/main/js/jquery-1.9.1.min.js" charset="utf-8"></script>
		<link rel="stylesheet" href="${httpRootPath}/resources/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="${httpRootPath}/resources/main/css/global.css">
	</head>

	<body>
	<#include "/z_head.html"/>
	<div class="layui-main site-inline">
		<div class="site-content">
			<h1 class="site-h1">用户管理</h1>
			<div class="layui-main">
				<blockquote class="layui-elem-quote">
					<button class="layui-btn layui-btn-small" onclick="touserAdd()"><i class="layui-icon"></i>添加用户</button>
					<div class="layui-form">
						<table class="layui-table" id="tableid">
							<colgroup>
								<col width="60">
								<col width="50">
								<col width="200">
								<col width="200">
								<col width="200">
								<col width="100">
							</colgroup>
							<thead>
							<tr>
								<th>序号</th>
								<th>用户名</th>
								<th>姓名</th>
								<th>角色</th>
								<th>权限</th>
								<th>操作</th>
							</tr>
							</thead>
							<tbody>
							</tbody>
						</table>
					</div>
					<div id="demo1" style="text-align: right;"></div>
				</blockquote>
			</div>
		</div>
	</div>
	<script>
        layui.use(['laypage', 'layer'], function(){
            loadData(1);
		});

        function loadData(curr, laypage) {
            var laypage = layui.laypage
                ,layer = layui.layer;
            $.getJSON('data/user_loaddata', {
                page: curr || 1, //向服务端传的参数，此处只是演示
                size :10
            }, function(res){
                if(res.code == 0){
                    createTable(res.data.content);
                    laypage({
                        cont: 'demo1', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
                        pages: res.data.totalPages, //通过后台拿到的总页数
                        groups: 5,
                        curr: curr || 1, //当前页
                        jump: function(obj, first){ //触发分页后的回调
                            if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                                loadData(obj.curr);
                            }
                        }
                    });
                }else{
					layer.alert(res.msg);
				}
            });
        }


        function createTable(list){
            $("#tableid tbody").empty();
            for(var i = 0; i < list.length; i++){
				var html = "<tr>";
                html = html + "<td>"+ (i+1) +"</td>";
                html = html + "<td>"+ list[i].f_username +"</td>";
                html = html + "<td>"+ list[i].f_realname +"</td>";
                html = html + "<td>"+ list[i].f_role +"</td>";
                html = html + "<td><button class='layui-btn layui-btn-mini'>查看权限</button></td>";
                html = html + "<td>";
                html = html + "<ul class='layui-nav' style='padding:0 0 0 0;width:80px;'>";
                html = html + "<li class='layui-nav-item lumingbao' style='line-height:30px;'>";
                html = html + "<style type='text/css'>";
                html = html + ".lumingbao .layui-nav-more{top:13px;}";
                html = html + ".lumingbao .layui-nav-mored{top:6px;}";
                html = html + ".lumingbao .layui-nav-child{top:30px;}";
                html = html + "</style>";
                html = html + "<a href='javascript:;'>操作</a>";
                html = html + "<dl class='layui-nav-child'>";
                html = html + "<dd><a href=''>设置用户</a></dd>";
                html = html + "<dd><a href=''>设置用户组</a></dd>";
                html = html + "<dd><a href=''>设置权限</a></dd>";
                html = html + "<dd><a href=''>删除</a></dd>";
                html = html + "</dl>";
                html = html + "</li>";
                html = html + "</ul>";
                html = html + "</td>";
                html = html + "</tr>";
                $("#tableid tbody").append(html);
            }
            loadUi();
		}

		function loadUi(){
            layui.use('element', function(){
                var element = layui.element(); //导航的hover效果、二级菜单等功能，需要依赖element模块
                element.init();
            });
		}

        function touserAdd(){
            window.location.href="userAdd.htm";
        }
	</script>
	</body>
</html>